﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;

namespace LUStationery.DAO
{
    public class SupplierDAO
    {
        SqlConnection cn;
        SqlCommand cmd;
        //ZHONG YUE\\
        public IDataReader getSupplier()
        {
            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            cmd = new SqlCommand("Select * from supplier", cn);
            cn.Open();
            IDataReader idr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return idr;
        }

        //ZHONG YUE\\
        public IDataReader getSupplierBySupplierName(string supplier)
        {
            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            cmd = new SqlCommand("Select * from supplier where supplier_name=@supplierName", cn);
            cmd.Parameters.Add("@supplierName", SqlDbType.VarChar).Value = supplier;
            cn.Open();
            IDataReader idr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return idr;
        }
    }
}
